<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
		<meta name="description" content="">
		<meta name="author" content="">
		<link rel="icon" href="../../favicon.ico">

		<title>注册</title>

		<!-- Bootstrap core CSS -->
		<!--link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"-->
		<link href="/javascripts/bootstrap.min.css" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="/javascripts/starter-template.css" rel="stylesheet">
		<link href="/javascripts/jquery.min.js">

	  <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
		<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
		<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
		<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
		<!--script src="./public/order.js"></script-->
		<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
		<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
		<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->

		<script type="text/javascript">
			$(document).ready(function(){
				$("#register").click(function(){
					var username = $('#username').val();
					var password = $("#password").val();
          var repassword = $("#repassword").val();
					var depart = $('#depart').val();
					if (depart == '请选择部门') {
						alert('请选择一个部门');
						return;
					}
					if (username.length === 0) {
						alert('用户名不能为空');
						return;
					}
					if (password.length === 0) {
						alert('密码不能为空');
						return;
					}
					if (repassword.length === 0) {
						alert('确认密码不能为空');
						return;
					}
					if (password !== repassword) {
						alert(password + '两次密码不一致' + repassword);
						return;
					} else {
						var data = {"username":username, "password":password, "depart":depart};
						$.ajax({
							url: '/register',
							type: 'post',
							data: data,
							success: function(data, status) {
								if (status == 'success') {
									location.href = '/login';
								}
							},
							error: function(data, err) {
								location.href = '/register';
							}
						});
					}
				});
			});
		</script>

	</head>

	<body screen_capture_injected="true">
		<div class="container">
			<%- message %>
			<div class="starter-template">
				<form class="form-horizontal logindiv" role="form" method="post">
					<div class="form-group" role="form">
							<label for="departName" class="col-sm-2 control-label">部门</label>
							<div class="col-sm-10">
								<select class="form-control " id="depart" name="depart">
									<option>请选择部门</option>
									<option>管理员</option>
									<option>生产</option>
									<option>运维</option>
									<option>财务</option>
									<option>营销</option>
									<option>行政</option>
								</select>
						</div>
					</div>
					<div class="form-group" role="form">
						<label for="username" class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="username"
							placeholder="请输入用户名" id="username">
						</div>
					</div>
					<div class="form-group">
						<label for="password" class="col-sm-2 control-label">密码</label>
						<div class="col-sm-10 ">
							<input type="password" class="form-control" name="password"
							placeholder="请输入密码" id="password">
						</div>
					</div>
          <div class="form-group">
						<label for="password" class="col-sm-2 control-label">确认密码</label>
						<div class="col-sm-10 ">
							<input type="password" class="form-control" name="repassword"
							placeholder="请输入确认密码" id="repassword">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-1 col-sm-10">
							<a class="btn btn-default btn-lg" href="/login" >返回</a>
              <button type="button" class="btn btn-default btn-lg" id="register" >注册</button>
            </div>
					</div>
				</form>
			</div>

		</div><!-- /.container -->


		<!-- Bootstrap core JavaScript
		================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<!--script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script-->
		<!--script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script-->
		<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
		<!--script src="../../assets/js/ie10-viewport-bug-workaround.js"></script-->
	</body>
</html>
